package net.kelissa.jenetic.impl.gene;

import net.kelissa.jenetic.Gene;
import net.kelissa.jenetic.RandomUtil;

public class GeneDouble extends GeneValueBase<Double>
{

  private double randMin = -1;

  private double randMax = 1;

  public GeneDouble(Double value)
  {
    super(value);
  }

  @Override
  public void mutate()
  {
    double rand = RandomUtil.getRandom(this.randMin, this.randMax);
    this.value += rand;
  }

  @Override
  public Gene clone()
  {
    return new GeneDouble(this.value);
  }

  @Override
  public int compareTo(Gene other)
  {
    Double otherValue = ((GeneDouble)other).getValue();
    return this.value.compareTo(otherValue);
  }

  //-------------------------------
  public double getRandMin()
  {
    return randMin;
  }

  public void setRandMin(double randMin)
  {
    this.randMin = randMin;
  }

  public double getRandMax()
  {
    return randMax;
  }

  public void setRandMax(double randMax)
  {
    this.randMax = randMax;
  }

}
